package com.ym.b2b.product.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.commons.dao.BaseDao;
import com.ym.b2b.product.dao.EmBProductTypeDAO;
import com.ym.b2b.product.sqlbean.EmBProductType;

@Repository("emBProductTypeDAO")
public class EmBProductTypeDAOImpl<T> extends BaseDao<T> implements EmBProductTypeDAO {

    public void insertEmBProductType(EmBProductType record) throws DataAccessException {
        insert("EM_B_PRODUCT_TYPE.insertEmBProductType", record);
    }

    public int updateEmBProductType(EmBProductType record) throws DataAccessException {
        int rows = update("EM_B_PRODUCT_TYPE.updateEmBProductType", record);
        return rows;
    }

    public EmBProductType showEmBProductTypeDetail(EmBProductType key) throws DataAccessException {

        return (EmBProductType) find("EM_B_PRODUCT_TYPE.searchEmBProductType", key);
    }

    public int deleteEmBProductType(EmBProductType emBProductType) throws DataAccessException {
        int rows = delete("EM_B_PRODUCT_TYPE.deleteEmBProductType", emBProductType);
        return rows;
    }

    @Override
    public List<EmBProductType> searchEmBProductType(EmBProductType emBProductType) throws DataAccessException {
        return list("EM_B_PRODUCT_TYPE.searchEmBProductType", emBProductType);
    }

    @Override
    public Long hasTheRootEmBProductType(EmBProductType emBProductType) throws DataAccessException {
        return (Long) find("EM_B_PRODUCT_TYPE.hasTheRootEmBProductType", emBProductType);
    }

    @Override
    public Integer searchTypeLevel() throws DataAccessException {

        return (Integer) find("EM_B_PRODUCT_TYPE.searchTypeLevel", null);
    }
}
